from points.models import PointConsume


class PointDB(object):
    """积分操作类"""
    model = PointConsume

    def create(self, **kwargs):
        """增加修改积分"""
        code = kwargs.pop("code")
        self.model.objects.update_or_create(code=code, defaults=kwargs)

    def remove(self, code):
        """删除积分"""
        self.model.objects.filter(code=code).delete()
